import { Component, Inject, OnInit } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';

@Component({
  selector: 'app-message-dialog',
  template: `
  <h1 matDiaglogTitle *ngIf="data.title"> {{ data.title }} </h1>
  <mat-dialog-content>
    <h2> {{ data.message }} </h2>
  </mat-dialog-content>
  <mat-dialog-actions align="end">
    <button mat-button mat-dialog-close>{{ data.cancelName || '取消' }}</button>
    <button mat-button [mat-dialog-close]="true" cdkFocusInitial color="accent"> {{ data.okName || '确定' }}</button>
  </mat-dialog-actions>
  `,
  styles: [``],
})
export class MessageDialogComponent implements OnInit {
  constructor(
    public dialogRef: MatDialogRef<MessageDialogComponent>,
    @Inject(MAT_DIALOG_DATA)
    public data: {
      title?: string;
      message: string;
      cancelName?: string;
      okName?: string;
    }
  ) {}

  ngOnInit(): void {}
}
